# -*- coding: utf-8 -*-
from django.db import models

class SongsHash(models.Model):
    hash = models.TextField('Song string')
    date_added = models.DateTimeField('Date added', auto_now_add=True)
    
    class Meta:
        verbose_name = u'Song Hash'
        verbose_name_plural = u'Songs Hashes'

class SongData(models.Model):
    song = models.ForeignKey(SongsHash)
    title = models.CharField('Song title', max_length=255)
    author = models.CharField('Song author', max_length=255, null=True)
    album = models.CharField('Song album', max_length=255, null=True)
    length = models.PositiveIntegerField('Song length', null=True)

    class Meta:
        verbose_name = u'Song Data'
        verbose_name_plural = u'Songs Data'

class SongsPart(models.Model):
    chunk = models.CharField('Part', max_length=10, unique=True)
    song = models.ManyToManyField(SongsHash)
    
    class Meta:
        verbose_name = u'Song Part'
        verbose_name_plural = u'Songs Parts'

    def songs(self):
        return self.songs.all()
